<template>
  <basic-container>
    <avue-crud
      :option="option"
      :search.sync="search"
      :table-loading="loading"
      :data="data"
      :page.sync="page"
      :permission="permissionList"
      :before-open="beforeOpen"
      v-model="form"
      ref="crud"
      @row-update="rowUpdate"
      @row-save="rowSave"
      @row-del="rowDel"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @sort-change="sortChange"
      @on-load="onLoad"
    >
      <template slot-scope="scope" slot="menu">
        <el-button
          v-if="permissionList.viewBtn"
          icon="el-icon-view"
          size="small"
          type="text"
          @click.stop="handleDetail(scope.row, scope.index)"
          >详 情</el-button
        >
      </template>
      <template slot="menuLeft">
        <!-- <el-button
          type="danger"
          size="small"
          icon="el-icon-delete"
          plain
          v-if="permission.pos_info_delete"
          @click="handleDelete"
          >删 除
        </el-button> -->
      </template>
      <!-- <template slot="menuRight">
        <el-button
          type="success"
          size="small"
          plain
          icon="el-icon-upload2"
          v-if="permission.pos_info_import"
          @click="handleImport"
          >导入
        </el-button>
        <el-button
          type="warning"
          size="small"
          plain
          icon="el-icon-download"
          v-if="permission.pos_info_export"
          @click="handleExport"
          >导出
        </el-button>
      </template> -->
      <template slot-scope="{row}"
            slot="accountManager">
        <span>{{row.accountManagerName}}</span>
      </template>
      <template slot-scope="{row}"
                slot="rpiExStatus">
        <el-tag type="success" :color="getColorRpiExStatus(row.rpiExStatus)" effect="dark">{{ row.rpiExStatusName?row.rpiExStatusName:'未提交' }}</el-tag>
      </template>
      <template slot-scope="{row}"
                slot="rpiStatus">
        <!-- <el-tag>{{ row.rpiStatusName }}</el-tag> -->
        <el-switch
          :active-value="1"
          :inactive-value="0"
          v-model="row.rpiStatus"
          @change="handleSwitch(row)"
          >
        </el-switch>
      </template>
    </avue-crud>
    <el-dialog
      title="数据导入"
      append-to-body
      :visible.sync="excelBox"
      width="555px"
    >
      <avue-form
        :option="excelOption"
        v-model="excelForm"
        :upload-after="uploadAfter"
      >
        <template slot="excelTemplate">
          <el-button type="primary" @click="handleTemplate">
            点击下载<i class="el-icon-download el-icon--right"></i>
          </el-button>
        </template>
      </avue-form>
    </el-dialog>
    <el-dialog
      title="变更归属服务商"
      append-to-body
      :close-on-click-modal="false"
      :visible.sync="dialogServiceVisible"
    >
      <avue-form ref="serveForm" :option="serveOption" v-model="serveForm" @submit="serveSubmit">
        <!-- <template slot="serveNo" slot-scope="{disabled}">
          <el-select v-model="form.serveNo" placeholder="请选择" :disabled="disabled" size="small">
            <el-option
              v-for="item in serveNoList"
              :key="item.serviceNo"
              :label="item.serviceName"
              :value="item.serviceNo">
              <span style="float: left">{{ item.serviceName }}</span>
              <span style="float: right; color: #8492a6; font-size: 13px">{{ item.serviceNo }}</span>
            </el-option>
          </el-select>
        </template> -->
      </avue-form>
    </el-dialog>
    <el-dialog
      title="变更归属集团商户"
      append-to-body
      :close-on-click-modal="false"
      :visible.sync="dialogGroupVisible"
    >
      <avue-form ref="groupForm" :option="groupOption" v-model="groupForm" @submit="groupSubmit">
        <!-- <template slot="rpiNo" slot-scope="{disabled}">
          <el-select v-model="form.rpiNo" placeholder="请选择" :disabled="disabled" size="small">
            <el-option
              v-for="item in rpiNoList"
              :key="item.rpiNo"
              :label="item.rpiName"
              :value="item.rpiNo">
              <span style="float: left">{{ item.rpiName }}</span>
              <span style="float: right; color: #8492a6; font-size: 13px">{{ item.rpiNo }}</span>
            </el-option>
          </el-select>
        </template> -->
      </avue-form>
    </el-dialog>
  </basic-container>
</template>

<script>
import {
  getDetail,
  add,
  update,
  onOrOffPosInfo,
  updateBelongService,
  updateBelongGroup,
  remove,
} from "@/api/rb-merchant/posinfo/pos_info";
import {
  getList,
} from "@/api/rb-merchant/posgroup/pos_group";
import { mapGetters } from "vuex";
import { getToken } from "@/util/auth";
// import { isMobile } from "@/util/validate";

// var serviceDic = [{
//   label:'包含下级',
//   value: 1
// }]
export default {
  components: {},
  data() {
    // const validatePhone = (rule, value, callback) => {
    //   if (value === "") {
    //     callback(new Error("请输入手机号"));
    //   } else if (!isMobile(value)) {
    //     callback(new Error("手机号码不正确！"));
    //   } else {
    //     callback();
    //   }
    // };
    return {
      form: {},
      query: {},
      search: {},
      screenWidth: document.documentElement.clientWidth,
      dialogServiceVisible: false,
      dialogGroupVisible: false,
      dialogType: "", //打开类型 add/edit
      merchantId: null,
      active: 0,
      openType: "", //打开dialog弹框的类型
      userType: "3",
      props: {
        //菜单权限数据 props
        label: "title",
        value: "key",
        disabled: this.isDisabledFn,
      },
      loading: true,
      excelBox: false,
      page: {
        pageSize: 10,
        currentPage: 1,
        // rpiKind: 1,
        total: 0,
      },
      selectionList: [],
      option: {
        // height: "auto",
        calcHeight: 30,
        tip: false,
        border: true,
        index: true,
        viewBtn: false,
        selection: true,
        searchMenuSpan: 6,
        // columnBtn: false,
        addBtn: false,
        editBtn: false,
        delBtn: false,
        searchLabelWidth: 120,
        column: [
          {
            label: "主键",
            prop: "id",
            type: "input",
            //sortable: true,
            addDisplay: false,
            editDisplay: false,
            viewDisplay: false,
            hide: true,
          },
          // {
          //   label: "服务商",
          //   prop: "serNo",
          //   type: "select",
          //   dicUrl: "/api/rb-merchant/service/serviceinfo/service_info/childServiceList?current=-1&size=-1",
          //   props: {
          //     label: "serviceName",
          //     value: "serviceNo",
          //     desc: "serviceNo"
          //   },
          //   dataType: "string",
          //   showColumn: false,
          //   search: true,
          //   filterable: true,
          //   hide: true,
          //   rules: [
          //     {
          //       required: true,
          //       message: "请选择服务商",
          //       trigger: "blur",
          //     },
          //   ],
          // },
        //   {
        //     label: '',
        //     prop: 'isAllSer',
        //     type:'select',
        //     multiple:false,
        //     dataType: "string",
        //     hide: true,
        //     search:true,
        //     searchType:"checkbox",
        //     searchSpan: 0,
        //     searchLabelWidth: '0',
        //     dicData: serviceDic
        //   },
          // {
          //   label: "客户经理",
          //   prop: "accountManager",
          //   type: "select",
          //   dicUrl: "/api/rb-merchant/merchant/posinfo/pos_info/accountManagerList?createUser={{key}}",
          //   props: {
          //     label: "userName",
          //     value: "userNo",
          //     desc: "userNo"
          //   },
          //   dataType: "string",
          //   showColumn: false,
          //   search: true,
          //   filterable: true,
          //   hide: true,
          //   rules: [
          //     {
          //       required: true,
          //       message: "请选择客户经理",
          //       trigger: "blur",
          //     },
          //   ],
          // },
        //   {
        //     label: "所属机构",
        //     prop: "serCompany",
        //     type: "select",
        //     dicUrl: "/api/rb-merchant/merchant/serviceinfo/service_info/childServiceListFirst?current=-1&size=-1",
        //     props: {
        //       label: "serviceName",
        //       value: "serviceNo",
        //       desc: "serviceNo"
        //     },
        //     dataType: "string",
        //     showColumn: false,
        //     search: true,
        //     filterable: true,
        //     hide: true,
        //     rules: [
        //       {
        //         required: true,
        //         message: "请选择服务商",
        //         trigger: "blur",
        //       },
        //     ],
        //   },
          {
            label: "集团商户编号",
            prop: "rpiGroup",
            type: "input",
            display: false,
            //sortable: true,
            search: true,
            rules: [
              {
                required: true,
                message: "请输入商户号",
                trigger: "blur",
              },
            ],
            overHidden: true,
            width: 150
          },
          {
            label: "集团商户名称",
            prop: "rpiGroupName",
            type: "input",
            search: true,
            rules: [
              {
                required: true,
                message: "请输入门头名称",
                trigger: "blur",
              },
            ],
            overHidden: true,
            width: 150
          },
          {
            label: "子商户编号",
            searchLabel: '商户编号',
            prop: "rpiNo",
            type: "input",
            display: false,
            search: true,
            rules: [
              {
                required: true,
                message: "请输入商户号",
                trigger: "blur",
              },
            ],
            overHidden: true,
            width: 150
          },
          // {
          //   label: "子门头名称",
          //   prop: "rpiName",
          //   type: "input",
          //   rules: [
          //     {
          //       required: true,
          //       message: "请输入门头名称",
          //       trigger: "blur",
          //     },
          //   ],
          //   overHidden: true,
          //   width: 150
          // },
          {
            label: "子商户注册名称",
            searchLabel: "注册名称",
            prop: "registeredName",
            type: "input",
            search: true,
            rules: [
              {
                required: true,
                message: "请输入注册名称",
                trigger: "blur",
              },
            ],
            overHidden: true,
            width: 150
          },
          {
            label: "企业类型",
            prop: "userTypeName",
            slot: true,
            display: false,
            overHidden: true,
            width: 100
          },
          {
            label: "商户简称",
            prop: "userShortName",
            type: "input",
            search: true,
            rules: [
              {
                required: true,
                message: "请输入商户简称",
                trigger: "blur",
              },
            ],
            overHidden: true,
            width: 150
          },
          {
            label: "法人名称",
            prop: "legalPersonName",
            type: "input",
            rules: [
              {
                required: true,
                message: "请输入法人名称",
                trigger: "blur",
              },
            ],
            search: true,
            showColumn: false,
            hide: true,
            overHidden: true,
            width: 150
          },
          // {
          //   label: "所属服务商",
          //   width: 100,
          //   prop: "serName",
          //   slot: true,
          //   display: false,
          //   overHidden: true,
          // },
          {
            label: "客户经理",
            width: 100,
            prop: "accountManagerName",
            slot: true,
            display: false,
            overHidden: true,
          },
          // {
          //   label: "归属商户",
          //   width: 100,
          //   prop: "rpiGroupName",
          //   slot: true,
          //   display: false,
          //   overHidden: true,
          // },
          {
            label: "商户类型",
            prop: "userType",
            type: "select",
            dicUrl: "/api/blade-system/dict/dictionary?code=user_income_type",
            props: {
              label: "dictValue",
              value: "dictKey",
            },
            dataType: "string",
            showColumn: false,
            hide: true,
            search: true,
            rules: [
              {
                required: true,
                message: "请输入商户类型",
                trigger: "blur",
              },
            ],
            overHidden: true,
          },
          {
            label: "结算名称",
            prop: "balanceAccName",
            type: "input",
            search: true,
            showColumn: false,
            hide: true,
            rules: [
              {
                required: true,
                message: "请输入结算人名称",
                trigger: "blur",
              },
            ],
            overHidden: true,
            width: 150
          },
          // {
          //   label: "联系人",
          //   prop: "contactName",
          //   search: true,
          //   rules: [
          //     {
          //       required: true,
          //       message: "请输入联系人",
          //       trigger: "blur",
          //     },
          //   ],
          //   overHidden: true,
          // },
          {
            label: "联系方式",
            prop: "contactsPhone",
            search: true,
            // rules: [
            //   {
            //     required: true,
            //     validator: validatePhone,
            //     trigger: "blur",
            //   },
            // ],
            overHidden: true,
            width:150
          },
          // {
          //   label: "归属集团",
          //   prop: "rpiGroup",
          //   type: "input",
          //   span: 24,
          //   //sortable: true,
          //   rules: [
          //     {
          //       required: true,
          //       message: "请输入归属集团",
          //       trigger: "blur",
          //     },
          //   ],
          // },
          {
            label: "省份",
            prop: "provinceName",
            slot: true,
            display: false,
            // hide: true,
          },
          {
            label: "地市",
            prop: "cityName",
            slot: true,
            display: false,
            // hide: true,
          },
          {
            label: "区县",
            prop: "areaName",
            slot: true,
            display: false,
            hide: true,
          },
          {
            label: "省份",
            prop: "province",
            type: "select",
            props: {
              label: "name",
              value: "code",
            },
            cascaderItem: ["city", "area"],
            dicUrl: "/api/blade-system/region/select",
            span: 8,
            showColumn: false,
            hide: true,
            rules: [
              {
                required: true,
                message: "请选择省份",
                trigger: "blur",
              },
            ],
          },
          {
            label: "地市",
            prop: "city",
            type: "select",
            props: {
              label: "name",
              value: "code",
            },
            dicUrl: "/api/blade-system/region/select?code={{key}}",
            span: 8,
            showColumn: false,
            hide: true,
            rules: [
              {
                required: true,
                message: "请选择地市",
                trigger: "blur",
              },
            ],
          },
          {
            label: "区县",
            prop: "area",
            type: "select",
            props: {
              label: "name",
              value: "code",
            },
            dicUrl: "/api/blade-system/region/select?code={{key}}",
            span: 8,
            showColumn: false,
            hide: true,
            rules: [
              {
                required: true,
                message: "请选择区县",
                trigger: "blur",
              },
            ],
          },
          {
            label: "详细地址",
            prop: "address",
            span: 24,
            minRows: 2,
            type: "textarea",
            hide: true,
            rules: [
              {
                required: true,
                message: "请输入详细地址",
                trigger: "blur",
              },
            ],
          },
          {
            label: "创建日期",
            prop: "createTime",
            width: 150,
            slot: true,
            span: 24,
            addDisplay: false,
            editDisplay: false,
          },
          {
            label: "商户状态",
            prop: "rpiStatus",
            type: "select",
            dicUrl: "/api/blade-system/dict/dictionary?code=rpi_status",
            props: {
              label: "dictValue",
              value: "dictKey",
            },
            value: "1",
            dataType: "string",
            showColumn: false,
            rules: [
              {
                required: true,
                message: "请输入商户状态",
                trigger: "blur",
              },
            ],
          },
          {
            label: "审核状态",
            prop: "rpiExStatus",
            type: "select",
            dicUrl: "/api/blade-system/dict/dictionary?code=rpi_ex_status",
            props: {
              label: "dictValue",
              value: "dictKey",
            },
            dataType: "string",
            showColumn: false,
            // search: true,
            rules: [
              {
                required: true,
                message: "请输入审核状态",
                trigger: "blur",
              },
            ],
          },
          {
            label: "审核备注",
            prop: "adminRemark",
            width: 150,
            overHidden:true,
            span: 24,
            addDisplay: false,
            editDisplay: false,
          },
          {
            label: "创建日期",
            prop: "dateTime",
            type: "datetimerange",
            searchRange: true,
            defaultTime:['00:00:00', '23:59:59'],
            format:'yyyy-MM-dd HH:mm:ss',
            valueFormat:'yyyy-MM-dd HH:mm:ss',
            startPlaceholder: "开始日期",
            endPlaceholder: "结束日期",
            search: true,
            rules: [
              {
                required: true,
                message: "请选择创建日期",
                trigger: "blur",
              },
            ],
            showColumn: false,
            hide: true,
            display: false,
            searchSpan: 12
          },
        ],
      },
      data: [],
      serveForm: {},
      serveOption: {
        column: [
          {
            label: "选择服务商",
            labelWidth: 100,
            prop: "serveNo",
            span: 24,
            minRows: 2,
            type: "select",
            filterable: true,
            formslot: true,
            props: {
              label: "serviceName",
              value: "serviceNo",
              desc:'serviceNo',
            },
            dicData: [],
            rules: [
              {
                required: true,
                message: "请选择服务商",
                trigger: "blur",
              },
            ],
          },
        ]
      },
      groupForm: {},
      groupOption: {
        column: [
          {
            label: "选择集团商户",
            labelWidth: 120,
            prop: "rpiNo",
            span: 24,
            minRows: 2,
            type: "select",
            filterable: true,
            props: {
              label: "rpiName",
              value: "rpiNo",
              desc:'rpiNo',
            },
            dicData: [],
            rules: [
              {
                required: true,
                message: "请选择集团商户",
                trigger: "blur",
              },
            ],
          },
        ]
      },
      serveNoList: [],
      rpiNoList: [],
      excelForm: {},
      excelOption: {
        submitBtn: false,
        emptyBtn: false,
        column: [
          {
            label: "模板上传",
            prop: "excelFile",
            type: "upload",
            drag: true,
            loadText: "模板上传中，请稍等",
            span: 24,
            propsHttp: {
              res: "data",
            },
            tip: "请上传 .xls,.xlsx 标准格式文件",
            action: "/api/rb-merchant/merchant/posinfo/pos_info/import",
          },
          {
            label: "模板下载",
            prop: "excelTemplate",
            formslot: true,
            span: 24,
          },
        ],
      },
    };
  },
  computed: {
    ...mapGetters(["permission"]),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permission.pos_info_add, false),
        viewBtn: this.vaildData(this.permission.pos_info_view, false),
        delBtn: this.vaildData(this.permission.pos_info_delete, false),
        editBtn: this.vaildData(this.permission.pos_info_edit, false),
      };
    },
    ids() {
      let ids = [];
      this.selectionList.forEach((ele) => {
        ids.push(ele.id);
      });
      return ids.join(",");
    },
    getColorRpiExStatus() {
      return state => {
        if (state == '0') {
          return '#E6A23C';
        } else if (state == '1') {
          return '#396afc';
        } else if (state == '2') {
          return '#E6A23C';
        } else if (state == '3') {
          return '#67C23A';
        } else if (state == '4') {
          return '#F56C6C';
        } else {
          return '#8e9eab';
        }
      }
    }
  },
  watch: {
    "search.dateTime"(val){
      if(val){
        this.search.beginTime = val[0];
        this.search.endTime = val[1];
      }else{
        this.search.beginTime = "";
        this.search.endTime = "";
      }
    }
  },
  created() {},
  methods: {
    /**
     * @func 五合一新增
     * @desc 点击新增初始化显示基本信息
     * */
    handleSave() {
      this.$router.push({
        name: "新增商户"
      });
      // this.$refs.toBasicForm.$refs['mcc'].panel.store.nodes = null;
    },
    /**
     * @func 提交已选归属服务商
     * @desc 提交已选归属服务商
     * */
    serveSubmit(row, done, loading) {
      updateBelongService({ids:this.ids, serveNo: row.serveNo}).then(
        () => {
          this.onLoad(this.page);
          this.dialogServiceVisible = false;
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          this.$refs.serveForm.resetForm();
          done();
        },
        (error) => {
          loading();
          window.console.log(error);
        }
      );
    },
    /**
     * @func 提交已选归属集团商户
     * @desc 提交已选归属集团商户
     * */
    groupSubmit(row, done, loading) {
      updateBelongGroup({ids:this.ids, rpiNo: row.rpiNo}).then(
        () => {
          this.onLoad(this.page);
          this.dialogGroupVisible = false;
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          this.$refs.groupForm.resetForm();
          done();
        },
        (error) => {
          loading();
          window.console.log(error);
        }
      );
    },
    /**
     * @func 详情
     * @desc 点击详情进入详情界面
     * @param {Object} row - 商户信息
     * */
    handleDetail(row) {
      this.$router.push({
        name: "集团商户详情",
        query: {
          id: row.id,
          rpiNo:row.rpiNo,
          rpiExStatus:row.rpiExStatus
        },
      });
    },
    /**
     * @func 开关
     * @desc 商户开关 禁用启用
     * @param {Object} row - 商户信息
     * */
    handleSwitch(row) {
      onOrOffPosInfo(row.id, row.rpiStatus).then(() => {
      },(error) => {
        row.rpiStatus = row.rpiStatus == 1 ? 0 : 1;
        window.console.log(error);
      });
    },
    rowSave(row, done, loading) {
      add(row).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          done();
        },
        (error) => {
          loading();
          window.console.log(error);
        }
      );
    },
    rowUpdate(row, index, done, loading) {
      update(row).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          done();
        },
        (error) => {
          loading();
          window.console.log(error);
        }
      );
    },
    rowDel(row) {
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          return remove(row.id);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
        });
    },
    handleDelete() {
      if (this.selectionList.length === 0) {
        this.$message.warning("请选择至少一条数据");
        return;
      }
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          return remove(this.ids);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          this.$refs.crud.toggleSelection();
        });
    },
    beforeOpen(done, type) {
      this.openType = type;
      if (["edit", "view"].includes(type)) {
        getDetail(this.form.id).then((res) => {
          this.form = res.data.data;
        });
      }
      done();
    },
    /**
     * @func 菜单权限树形是否禁止
     * @desc dialog打开类型为 view 则禁止权限树
     * @param {String} openType - 打开类型
     * */
    isDisabledFn() {
      const _this = this;
      if (["view"].includes(_this.openType)) {
        return true;
      }
    },
    /**
     * @func 重置
     * @desc 重置查询条件
     * */
    searchReset() {
      this.query = {};
      this.$set(this.search, 'dateTime', ["",""])
      this.onLoad(this.page);
    },
    /**
     * @func 搜索
     * @desc 根据条件查询
     * @param {Object} params --- 条件查询
     * */
    searchChange(params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    },
    selectionChange(list) {
      this.selectionList = list;
    },
    selectionClear() {
      this.selectionList = [];
      this.$refs.crud.toggleSelection();
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    /**
     * @func 初始化加载
     * @desc 初始化加载
     * */
    onLoad(page, params = {}) {
      this.loading = true;
      getList(
        page.currentPage,
        page.pageSize,
        Object.assign(params, this.query)
      ).then((res) => {
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
        this.loading = false;
        this.selectionClear();
      });
    },
    handleImport() {
      this.excelBox = true;
    },
    /**
     * @func 导出
     * @desc 根据条件导出
     * */
    handleExport() {
      let exQuery = ``;
      exQuery += `&rpiGroupName=${this.search.rpiGroupName}`;
      exQuery += `&rpiGroup=${this.search.rpiGroup}`;
      exQuery += `&rpiName=${this.search.rpiName}`;
      exQuery += `&rpiNo=${this.search.rpiNo}`;
      exQuery += `&province=${this.search.province}`;
      exQuery += `&city=${this.search.city}`;
      exQuery += `&area=${this.search.area}`;
      exQuery += `&rpiExStatus=${this.search.rpiExStatus}`;
      exQuery += `&rpiStatus=${this.search.rpiStatus}`;
      exQuery += `&rpiType=${this.search.rpiType}`;
      exQuery += `&rpiToken=${this.search.rpiToken}`;
      exQuery += `&rpiMccCode=${this.search.rpiMccCode}`;
      exQuery += `&rpiMccName=${this.search.rpiMccName}`;
      if (this.search.timeData[0]) {
        exQuery += `&beginTime=${this.search.timeData[0]}`;
      }
      if (this.search.timeData[1]) {
        exQuery += `&endTime=${this.search.timeData[1]}`;
      }
      this.$confirm("是否导出用户数据?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        window.open(
          `/api/rb-merchant/merchant/posinfo/pos_info/export?${
            this.website.tokenHeader
          }=${getToken()}` + exQuery
        );
      });
    },
    handleTemplate() {
      window.open(
        `/api/rb-merchant/merchant/posinfo/pos_info/export-template?${
          this.website.tokenHeader
        }=${getToken()}`
      );
    },
    uploadAfter(res, done) {
      this.excelBox = false;
      this.refreshChange();
      done();
    },
    sortChange(val) {
      if (val.order == "ascending") {
        //正序
        this.query.ascs = val.prop;
        this.query.descs = "";
      } else {
        //倒序
        this.query.descs = val.prop;
        this.query.ascs = "";
      }
      this.refreshChange();
    },
  },
};
</script>

<style lang="scss" scoped>
/deep/ .el-tag--dark.el-tag--success {
  border-color: transparent;
  opacity: 0.8;
}
</style>